//
//  MonitorViewController.h
//  VCS_WS_ClientTest
//
//  Created by hu_danyuan on 18/11/14.
//  Copyright © 2018年 hudanyuan. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <GLKit/GLKit.h>

#import "MonitorInfoOverlayView.h"

enum
{
    MonitorStreamQualityHigh = 0,
    MonitorStreamQualityNormal,
    MonitorStreamQualityLow
};
typedef NSInteger MonitorStreamQuality;

typedef NS_ENUM(NSInteger, VideoPlayerViewContentMode) {
    VideoPlayerViewContentModeOrigin,
    VideoPlayerViewContentModeScaleToFill,
    VideoPlayerViewContentModeScaleAspectFit,  // contents scaled to fit with fixed aspect. remainder is transparent
    VideoPlayerViewContentModeScaleAspectFill, // contents scaled to fill with fixed aspect. some portion of content may be clipped.
};

// 声明代理
@protocol ToVcsWsVideoDelegate <NSObject>
// 代理方法
- (void)notifyWebView:(NSString *)msg;
@end

@interface MonitorViewController : UIViewController <VCS_WS_VideoMonitorDelegate, IAVPLAY_PlayCallback, IAVPLAY_AudioRecordCallback> {
    BOOL _isMute;      // 是否静音
    BOOL _isVoiceTalk; // 是否启动对讲
    BOOL _isOpenVideo; // 是否打开视频
    BOOL _isOpenVoice; // 是否打开语音
    BOOL _isRecording; // 是否正在录制视频
    BOOL _isFirstFrame;
    BOOL _bVoiceComSuccess; // 对讲是否打开成功
    uint8_t _lastEncodeType;

    int _nVideoWidth;  // 视频宽
    int _nVideoHeight; // 视频高
    NSInteger _nStreamQuality;

    VCS_WS_AudioFrameInfo *_voiceFrameInfo;
    WCS_WS_VideoMonitor *_videoMonitor;
    AVPLAY_HANDLE _player; // 视频播放器
    uint32_t _frameid;     // 视频帧id
    uint32_t _audioid;     // 音频帧id
    NSInteger _audioStreamId;
    NSInteger _voiceStreamId;
    //uint8_t _mempool[SH_MAX_SUPPORT_WIDTH * SH_MAX_SUPPORT_HEIGHT * 2]; // 缓存池
    //SHImageTool *_imageEncode; // h264转UIImage编码器
    //SHVideoMonitor *_videoMonitor; // 视频开关

    // 播放音乐，录音
    //SHAudioFrameInfo* _supportedAudioInfo;
    int _nAudioEncoderType;
    int _nAudioDecoderType;
    //short* _audioCaches; // 解码缓存
    AVPLAY_HANDLE _audioRecorder; // 录音

    // 图层信息
    MonitorInfoOverlayView *_videoInfoView;
}

@property(nonatomic, assign) VideoPlayerViewContentMode contentMode;
@property(nonatomic, strong) NSDictionary *options;
@property(nonatomic, weak) id<ToVcsWsVideoDelegate> delegate;
@property(atomic, assign) BOOL quit;
@property(strong, nonatomic) IBOutlet GLKView *glkView;

@end
